/*
 * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.ahoo.wow.api.messaging.function

/**
 * Represents information about a function in the messaging system.
 *
 * This interface combines function naming and identification with function kind
 * classification, providing complete metadata about functions that process messages.
 * Functions are identified by their kind (command, event, etc.), context, processor,
 * and name, allowing for precise routing and invocation.
 */
interface FunctionInfo :
    NamedFunctionInfo,
    FunctionKindCapable {
    /**
     * Determines if this function info represents the same function as another.
     *
     * Two function infos are considered the same if they have identical function kind,
     * processor name, context name, and function name. This is used for function
     * deduplication, routing decisions, and equality comparisons.
     *
     * @param functionInfo The function info to compare with this one
     * @return `true` if both function infos represent the same function, `false` otherwise
     */
    fun isSameFunction(functionInfo: FunctionInfo): Boolean =
        this.functionKind == functionInfo.functionKind &&
            this.processorName == functionInfo.processorName &&
            this.contextName == functionInfo.contextName &&
            this.name == functionInfo.name
}
